//
//  ViewController.m
//  Kfangchan
//
//  Created by liran on 14/11/5.
//  Copyright (c) 2014年 Beijing Renjuren Network Technology Co., Ltd. All rights reserved.
//

#import "ViewController.h"
#import "NavigationController.h"
#import "TabBarView.h"
#import "BuildingViewController.h"
#import "CustomerViewController.h"
#import "CommissionViewController.h"
#import "MoreViewController.h"

@interface ViewController ()<TabbarDelegate> {
    TabBarView  *tabBarView;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 楼盘
    BuildingViewController *buildingViewController = [[BuildingViewController alloc] init];
    UINavigationController *buildingNavigationController = [[NavigationController alloc] initWithRootViewController:buildingViewController];
    
    // 客户
    CustomerViewController *customerViewController = [[CustomerViewController alloc] init];
    UINavigationController *customerNavigationController = [[NavigationController alloc] initWithRootViewController:customerViewController];
    
    // 佣金
    CommissionViewController *commissionViewController = [[CommissionViewController alloc] init];
    UINavigationController *commissionNavigationController = [[NavigationController alloc] initWithRootViewController:commissionViewController];
    
    // 更多
    MoreViewController *moreViewController = [[MoreViewController alloc] init];
    UINavigationController *moreNavigationController = [[NavigationController alloc] initWithRootViewController:moreViewController];
    
    NSArray *viewControllers = [NSArray arrayWithObjects:buildingNavigationController,
        customerNavigationController,
        commissionNavigationController,
        moreNavigationController,
        nil];
    self.viewControllers = viewControllers;
    
    tabBarView = [[TabBarView alloc] init];
    tabBarView.delegate = self;
    [self.tabBar addSubview:tabBarView];
    [self tabbarDidSelectIndex:0];
    
}

- (void)didSelectedIndex:(int)index
{
    self.selectedIndex = index;
}

- (void) tabbarDidSelectIndex:(int)index
{
    [tabBarView setIndex:index];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
